﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.DotNet.Scaffolding.Shared.CodeModifier.CodeChange;
using Single.Core.Service;
using Single.Sys.Entity;
using Single.WebApp.Components;

namespace Single.WebApp.Areas.Sys.Controllers
{
    [Area("Sys")]
    public class OrgController : WorkController
    {
        public IActionResult Index()
        {
            return View();
        }

        public string Get(long id)
        {
            var entity = ServiceSysProps.SysOrg.Get(id);

            return ServiceResult.SerializeData(entity);
        }

        public string GetData(string code, string title)
        {
            var rows = ServiceSysProps.SysOrg.GetData(code, title);

            return ServiceResult.SerializeData(new { rows });
        }

        public string Save(SysOrg entity)
        {
            return ServiceSysProps.SysOrg.InsertOrUpdate(entity).Serialize();
        }

        public string Delete(long[] ids)
        {
            return ServiceSysProps.SysOrg.Delete(ids).Serialize();
        }
    }
}
